package com.jianneng.jdg.model.homeactivity;

import java.util.List;

import com.example.com.jianneng.jdg.R;
import com.example.com.jianneng.jdg.R.id;
import com.example.com.jianneng.jdg.R.layout;
import com.jianneng.jdg.model.adapter.ActivitiesListAdapter;
import com.jianneng.jdg.model.gallery.ActivityListService;
import com.jianneng.jdg.model.user.ActivitiesInfo;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.Toast;

public class ActivitiesActivity extends BaseActivity {
	private ListView mListView;
	private LinearLayout mBack;
	private ActivitiesListAdapter mAdapter;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_activities);
		init();
		final List<ActivitiesInfo> list = ActivityListService.getActivitiesList();
		mAdapter = new ActivitiesListAdapter(this,list );
		mListView.setAdapter(mAdapter);
		mListView.setOnItemClickListener(new OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
				ActivitiesInfo info = list.get(position);
				Intent intent = new Intent(ActivitiesActivity.this, ActivitiesDetailsActivity.class);
				intent.putExtra("activity_detail", info);
				startActivity(intent);
				
			}
		});
	}

	private void init() {
		mListView = (ListView) findViewById(R.id.activities_listview);
		mBack = (LinearLayout) findViewById(R.id.activities_back);
		mBack.setOnClickListener(new MyOnClickListener());
	}

	public class MyOnClickListener implements OnClickListener {

		@Override
		public void onClick(View v) {
			switch (v.getId()) {
			case R.id.activities_back:
				finish();
				break;
			
			default:
				break;
			}

		}

	}

}
